$(function () {

    // 点击登录按钮
    $("#btn_login").click(function () {


        var adminName = $("#adminName").val();
        var adminPassword = $("#adminPassword").val();;

        if(adminName == null || adminName == ""){
            $("#msg").html("用户名不能为空！");
            return false;
        }else if(adminPassword == null || adminPassword == ""){
            $("#msg").html("密码不能为空！");
            return false;
        }

        var basepath = $("#basepath").val();
        console.log(basepath);

        $.ajax({
            url:basepath+"/doLogin",
            type:"post",
            dataType:"json",
            data:$("#adminlogin").serialize(),
            success:function (data) {
                console.log(data)
                $("#btn_login").val("登录");
                if (data.success) {
                    location.href = basepath+"index.jsp";
                } else {
                    $("#msg").html("用户名或密码错误");

                }
            },
            beforeSend:function () {
                $("#btn_login").val("登录中...");
            },
            error:function () {
                $("#msg").html("系统错误请稍后再试");
            }
        });

    });
});